<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of admin
 *
 * @author QUYET
 */
class Admin extends Admin_Controller{
    //put your code here
    public function __construct() {
        parent::__construct();
        $this->load->helper('json');
        $this->load->model('News_m');
    }
    function index(){
        $this->listing();
    }
    function listing(){
        $this->data['module_title']='Quản lý tin tức';
        $this->template->set_hook('TOOLBAR', 'news_toolbar')
                ->build('admin/listing',$this->data);
    }
    
    function display_grid($lang_id=1){ 
        echo out_json('id_news', 'id_news', " 
                    es_news_lang.id_news,
                    es_news.image,
                    es_news_lang.title,
                    es_news_lang.meta_title,
                    es_news_lang.meta_description,
                    es_news_lang.meta_keywords,
                    es_news.posted_by,
                    users_profiles.display_name,
                    es_news_lang.content,
                    es_category_lang.name,
                    DATE(es_news.posted_time) as posted_time
                    FROM es_news , es_news_lang, es_category_lang,users_profiles 
                    WHERE es_news.id = es_news_lang.id_news
                    AND es_news.id_category = es_category_lang.id_category
                    AND es_news_lang.id_lang = es_category_lang.id_lang
                    AND es_news.posted_by = users_profiles.user_id
                    AND es_news_lang.id_lang = ".$lang_id."
                    ORDER BY es_news.id DESC");
    }
    
    function json_user_data(){
        echo ('{identifier:"id",label:"name",items:'.$this->News_m->get_users().'}');
    }
}

?>
